package com.shudes.pt.container;

import java.util.*;

import com.shudes.pt.pojo.*;

public class GamePlayerContainerMap {

	protected Map<Game, GamePlayerContainer> map;
	
	
	public GamePlayerContainerMap() { 
		map = new HashMap<Game, GamePlayerContainer>();
	}
	
	public GamePlayerContainerMap(Collection<GamePlayer> gps) 
	{
		this(); 
		for(GamePlayer g : gps)
			addGamePlayer(g); 
	}
	
	public void addContainer(GamePlayerContainer c) {
		map.put(c.getGame(), c);
	}
	
	public void addGamePlayer(GamePlayer gp) { 
		GamePlayerContainer c; 
		c = map.get(gp); 
		if(c==null) 
			c = new GamePlayerContainer(gp.getGame()); 
		c.addGamePlayer(gp);
		map.put(gp.getGame(), c);  
	}
	
	public Map<Game, GamePlayerContainer> asMap() {
		return Collections.unmodifiableMap(map);
	}
	
}
